<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <%include("/common/header.html",{title:''}){}%>
    <title>安全设置</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" media="screen" href="css/login/style.css">
    <link rel="stylesheet" type="text/css" href="css/login/reset.css"/>
    <style>
        .layui-elem-quote {
            background-color: inherit !important;
        }

        .layui-input, .layui-select, .layui-textarea {
            background-color: inherit;
            padding-left: 30px;
        }

        #wxImg {
            display: none;
        }

        #movse:hover #wxImg {
            display: block;
        }

        #movse:hover #aa {
            color: #009688;
        }

        #wx {
            display: none;
        }

        #gzh:hover #wx {
            display: block;
        }

        #gzh:hover #bb {
            color: #009688;
        }
    </style>
</head>
<body>
<div class="x-nav" style="margin: 20px auto auto 15px;">
      <span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
        <a href="javascript:;">首页</a><span lay-separator="">/</span>
        <a href="javascript:;">修改密码</a><span lay-separator=""></span>
          <!--        <a><cite>安全设置</cite></a>-->
      </span>
    <a class="layui-btn layui-btn-primary layui-btn-small" style="margin: -5px 14px 0px 0px;float:right;"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh-3"></i>
    </a>
</div>

<form class="layui-form" action="" style="margin-top: 20px">

    <div class="layui-form-item">
        <label class="layui-form-label">原始密码:</label>
        <div class="layui-input-inline">
            <input type="password" id="passWord" lay-verify="oldPwd" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">新密码:</label>
        <div class="layui-input-inline">
            <input type="password" name="passWord" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">确认密码:</label>
        <div class="layui-input-inline">
            <input type="password" lay-verify="required|confirmPass" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<%include("/common/foot.html"){}%>

<script src="js/login/particles.min.js"></script>
<script src="js/login/app.js"></script>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script>

<script>
    layui.use(['index', 'table', 'form', 'laydate', 'layedit', 'AjaxCommon', 'AliangLayui'], function () {
        var $ = layui.$;
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        var upload = layui.upload;
        var layedit = layui.layedit;
        var AliangLayui = layui.AliangLayui;
        var index;


        //富文本编辑器
        layedit = layui.layedit;
        var update_url = 'system/passWord/updatePassWord.jhtml';


        // 校验两次密码是否一致
        form.verify({
            oldPwd : function(value){
                if (value.length == 0) {
                    return '请输入旧密码';
                }
                var oldPassWord='${session.om_user.passWord}'
                // alert(oldPassWord)
                if (value.trim()!==oldPassWord){
                    return "旧密码输入错误，请重新输入！";
                }
            },
            confirmPass:function(value){
                if($('input[name=passWord]').val() !== value)
                    return '两次密码输入不一致！';
            }
        });

        form.on('submit(demo1)', function (data) {
            // alert(data.field.passWord)
            postUpdate(data.field.passWord);
            return false;
        });
        //ajax提交修改内容
        window.postUpdate = function (data) {
            $.ajax({
                url:update_url,
                type: "POST",
                data: {
                    "passWord":data
                },
                dataType: "json",
                success: function (ret) {
                    // alert(JSON.stringify(ret))
                    // window.location.href="logout.jhtml"
                    window.parent.window.location.reload();
                    // table.reload('listReload');
                }
            })
        }


    });

</script>
</html>